//
//  PendApprovalAddNewApprovalTableViewCell.m
//  ZJControlsClass
//
//  Created by mac on 2024/12/11.
//

#import "PendApprovalAddNewApprovalTableViewCell.h"

@implementation PendApprovalAddNewApprovalTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self configUI];
    }
    return self;
}



-(void)approvalParamer:(NSMutableDictionary * )dic{
        
    
    self.titleLabel.text = @"审批";
    self.leftOnetLabel.text = @"审批人";
    self.leftTwoLabel.text = @"审批时间";
    self.leftThreeLabel.text = @"审批结果";
    self.leftFourLabel.text = @"审批意见";
    
    self.rightOneLabel.text = [NSString stringWithFormat:@"%@/%@",dic[@"user"][@"orgName"],dic[@"user"][@"name"]];
    self.rightTwoLabel.text = [NSString stringWithFormat:@"%@",dic[@"endTime"]];
    if ([dic[@"result"] isEqualToString:@"agree"]){
        self.rightThreeLabel.text = @"同意";
    }else{
        self.rightThreeLabel.text = @"不同意";
    }
    self.rightFourLabel.numberOfLines = 0;
    self.rightFourLabel.text = ![dic[@"option"] isKindOfClass:[NSNull class]] ? [NSString stringWithFormat:@"%@",dic[@"option"][@"comments"]] : @"";
    
    
    CGFloat height = ![dic[@"option"] isKindOfClass:[NSNull class]] ? 
        [self.rightFourLabel.text boundingRectWithSize:CGSizeMake(SCREEN_WIDTH - 60, MAXFLOAT)
                                             options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
                                          attributes:@{NSFontAttributeName:self.rightFourLabel.font}
                                             context:nil].size.height : ALIGN_HEIGHT_PT(45);
    height = MAX(height, ALIGN_HEIGHT_PT(45));
    
    [self.rightFourLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@(height));
    }];
    
    [self.V mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.leftOnetLabel.mas_left);
        make.right.equalTo(self.rightOneLabel.mas_right);
        make.top.equalTo(self.rightFourLabel.mas_bottom);
        make.height.equalTo(@(1));
    }];
        

    
}


- (void)configUI {
    
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.leftOnetLabel];
    [self.contentView addSubview:self.rightOneLabel];
    [self.contentView addSubview:self.leftTwoLabel];
    [self.contentView addSubview:self.rightTwoLabel];
    [self.contentView addSubview:self.leftThreeLabel];
    [self.contentView addSubview:self.rightThreeLabel];
    [self.contentView addSubview:self.leftFourLabel];
    [self.contentView addSubview:self.rightFourLabel];
    [self.contentView addSubview:self.V];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(15);
        make.right.equalTo(self.contentView).offset(-15);
        make.height.equalTo(@(ALIGN_HEIGHT_PT(45)));
    }];
    
    [self.leftOnetLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLabel.mas_bottom);
        make.left.equalTo(self.contentView).offset(15);
        make.height.equalTo(@(ALIGN_HEIGHT_PT(45)));
    }];
    
    [self.rightOneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.leftOnetLabel);
        make.height.equalTo(@(ALIGN_HEIGHT_PT(45)));
        make.right.equalTo(self.contentView).offset(-15);
    }];
    
    [self.leftTwoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.leftOnetLabel.mas_bottom);
        make.left.equalTo(self.contentView).offset(15);
        make.height.equalTo(@(ALIGN_HEIGHT_PT(45)));
    }];
    
    [self.rightTwoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.leftTwoLabel);
        make.height.equalTo(@(ALIGN_HEIGHT_PT(45)));
        make.right.equalTo(self.contentView).offset(-15);
    }];
    
    [self.leftThreeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.leftTwoLabel.mas_bottom);
        make.left.equalTo(self.contentView).offset(15);
        make.height.equalTo(@(ALIGN_HEIGHT_PT(45)));
    }];
    
    [self.rightThreeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.leftThreeLabel);
        make.height.equalTo(@(ALIGN_HEIGHT_PT(45)));
        make.right.equalTo(self.contentView).offset(-15);
    }];
    
    [self.leftFourLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.leftThreeLabel.mas_bottom);
        make.left.equalTo(self.contentView).offset(15);
        make.height.equalTo(@(ALIGN_HEIGHT_PT(45)));
    }];
    
    [self.rightFourLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.leftFourLabel);
        make.left.equalTo(self.leftFourLabel.mas_right).with.offset(10);
        make.height.equalTo(@(ALIGN_HEIGHT_PT(45)));
        make.right.equalTo(self.contentView).offset(-15);
    }];
    
    [self.V mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.leftOnetLabel.mas_left);
        make.right.equalTo(self.rightOneLabel.mas_right);
        make.top.equalTo(self.rightFourLabel.mas_bottom);
        make.height.equalTo(@(1));
    }];
    
    
}

#pragma mark - Lazy Load
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = [UIFont systemFontOfSize:16 weight:0.3];
        _titleLabel.textColor = [UIColor blackColor];
    }
    return _titleLabel;
}

- (UILabel *)leftOnetLabel {
    if (!_leftOnetLabel) {
        _leftOnetLabel = [[UILabel alloc] init];
        _leftOnetLabel.font = FONT14;
        _leftOnetLabel.textColor = [UIColor grayColor];
    }
    return _leftOnetLabel;
}

- (UILabel *)rightOneLabel {
    if (!_rightOneLabel) {
        _rightOneLabel = [[UILabel alloc] init];
        _rightOneLabel.font = [UIFont systemFontOfSize:14];
        _rightOneLabel.textColor = [UIColor blackColor];
    }
    return _rightOneLabel;
}

- (UILabel *)leftTwoLabel {
    if (!_leftTwoLabel) {
        _leftTwoLabel = [[UILabel alloc] init];
        _leftTwoLabel.font = [UIFont systemFontOfSize:14];
        _leftTwoLabel.textColor = [UIColor grayColor];
    }
    return _leftTwoLabel;
}

- (UILabel *)rightTwoLabel {
    if (!_rightTwoLabel) {
        _rightTwoLabel = [[UILabel alloc] init];
        _rightTwoLabel.font = [UIFont systemFontOfSize:14];
        _rightTwoLabel.textColor = [UIColor blackColor];
    }
    return _rightTwoLabel;
}

- (UILabel *)leftThreeLabel {
    if (!_leftThreeLabel) {
        _leftThreeLabel = [[UILabel alloc] init];
        _leftThreeLabel.font = [UIFont systemFontOfSize:14];
        _leftThreeLabel.textColor = [UIColor grayColor];
    }
    return _leftThreeLabel;
}

- (UILabel *)rightThreeLabel {
    if (!_rightThreeLabel) {
        _rightThreeLabel = [[UILabel alloc] init];
        _rightThreeLabel.font = [UIFont systemFontOfSize:14];
        _rightThreeLabel.textColor = [UIColor blackColor];
    }
    return _rightThreeLabel;
}

- (UILabel *)leftFourLabel {
    if (!_leftFourLabel) {
        _leftFourLabel = [[UILabel alloc] init];
        _leftFourLabel.font = [UIFont systemFontOfSize:14];
        _leftFourLabel.textColor = [UIColor grayColor];
    }
    return _leftFourLabel;
}

- (UILabel *)rightFourLabel {
    if (!_rightFourLabel) {
        _rightFourLabel = [[UILabel alloc] init];
        _rightFourLabel.font = [UIFont systemFontOfSize:14];
        _rightFourLabel.textColor = [UIColor blackColor];
        _rightFourLabel.textAlignment = NSTextAlignmentRight;
    }
    return _rightFourLabel;
}



-(UIView *)V{
    if (!_V){
        _V = [UIView new];
        _V.backgroundColor = COLOR_RGB(244, 244, 244);
    }
    return _V;
}


@end
